Add avif_off_t and avif_fseeko() and avif_ftello()#3094
Add avif_off_t and avif_fseeko() and avif_ftello()#3094wantehchang wants to merge 1 commit intoAOMediaCodec:mainfrom
Conversation
Add simple wrappers around POSIX's fseeko() and ftello() and Windows' _fseeki64() and _ftelli64().
|
|
||
| if (size > 0) { | ||
| if (offset > LONG_MAX) { | ||
| if (offset > INT64_MAX) { |
There was a problem hiding this comment.
James: This is the only weakness of this pull request. There is no symbolic constant such as OFF_MAX for the maximum value of the off_t type. So here we assume without checking that off_t is 64 bits. (off_t is a signed integer by definition.)
This check ensures that it is safe to cast offset to avif_off_t at line 147.
There was a problem hiding this comment.
Nothing common anyway. I see gcc/clang report #define __OFF_T_MATCHES_OFF64_T 1. I wonder if it's worth adding a compile time assert in the posix path for sizeof(off_t) == 8?
| // Copyright 2020 Joe Drago. All rights reserved. | ||
| // SPDX-License-Identifier: BSD-2-Clause | ||
|
|
||
| #if !defined(_WIN32) |
There was a problem hiding this comment.
I was thinking cygwin/mingw might support this, but they should also support the windows specifics you added. We can test this if the toolchains are covered by the presubmit.
|
|
||
| if (size > 0) { | ||
| if (offset > LONG_MAX) { | ||
| if (offset > INT64_MAX) { |
There was a problem hiding this comment.
Nothing common anyway. I see gcc/clang report #define __OFF_T_MATCHES_OFF64_T 1. I wonder if it's worth adding a compile time assert in the posix path for sizeof(off_t) == 8?
Add simple wrappers around POSIX's fseeko() and ftello() and Windows' _fseeki64() and _ftelli64().